/*
* 四川生学教育科技有限公司
* Copyright (c) 2015-2025 Founder Ltd. All Rights Reserved.
*
* This software is the confidential and proprietary information of
* Founder. You shall not disclose such Confidential Information
* and shall use it only in accordance with the terms of the agreements
* you entered into with Founder.
*
*/
package cn.demo.kafka.demo1;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

/**
 * @author WUANG (wa@sxw.cn)
 * @description PropertyUtils
 * @date 2018/11/8 10:25
 * @slogon 站在巨人的肩膀上
 * @since 2.0.0
 */
public class PropertyUtils {
    private PropertyUtils() {

    }

    public static Properties load(File file) throws IOException {

        InputStream in = null;
        try {
            in = new FileInputStream(file);
            Properties props = new Properties();
            props.load(in);

            return props;

        } finally {
//            IoUtils.closeQuietly(in);
            in.close();
        }
    }

    public static Properties load(String path) throws IOException {

        InputStream in = null;
        try {
            in = PropertyUtils.class.getClassLoader().getResourceAsStream(path);
            Properties props = new Properties();
            props.load(in);

            return props;

        } finally {
//            IoUtils.closeQuietly(in);
            in.close();
        }
    }
}